package com.emser.unc.restlet.manager;

import java.io.Serializable;
import java.util.concurrent.Callable;

import org.restlet.data.ChallengeScheme;
import org.restlet.resource.ClientResource;

import com.emser.unc.restlet.NoSaleReportResource;
import com.emser.unc.serializable.NoSaleReportDTO;

public class NoSaleReportTransferManager extends TransferManager implements Callable<String>{
	
	private NoSaleReportDTO noSaleReportDTO;
	private NoSaleReportResource noSaleResource;
	private Boolean response;
	
	@Override
	public void setParams(String url, String userRest, String PassRest) {
		// TODO Auto-generated method stub
		noSaleReportDTO = new NoSaleReportDTO();
		ClientResource cr = new ClientResource(url);
		cr.setRequestEntityBuffering(true);
		cr.setChallengeResponse(ChallengeScheme.HTTP_BASIC, userRest, PassRest);
		noSaleResource = cr.wrap(NoSaleReportResource.class);
	}
	
	@Override
	public void setRequest(Serializable objectDTO) {
		// TODO Auto-generated method stub
		this.noSaleReportDTO = (NoSaleReportDTO)objectDTO;
	}
	
	@Override
	public Serializable getResponse() {
		// TODO Auto-generated method stub
		return response;
	}
	
	@Override
	public String call() throws Exception {
		// TODO Auto-generated method stub
		response = Boolean.FALSE;
		response = noSaleResource.putNoSaleReport(noSaleReportDTO);
		return null;
	}
}
